package gui;
/*
 * Programming graphical user interfaces
 * Example: DrawImage.java
 * Jarkko Leponiemi 2003
 */

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class DrawImage extends JPanel {
   
   private Image img = null;
   private int width,height;
   private VideoPanel vp ;
   public DrawImage(int w,int h){
	   	width = w;
	   	height = h;
	   	JFrame frame = new JFrame();
	   	
	   	// create and add an event handler for window closing event
	   	frame.addWindowListener(new WindowAdapter() {
	   		public void windowClosing(WindowEvent e) {
	   			System.exit(0);
	   		}
	   	});
	   	// add a panel to the window
//	   	f.add
	   	frame.getContentPane().add(this);
	   	frame.setBounds(0, 0, 1400, 700);
	   	
//	   	vp= new VideoPanel(w, h);
//	   	frame.add(vp);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
	   	frame.show();  
   }
   public void draw(Image image) {
      img = image;
//      vp.img = image;
      
   }
   public void paint(Graphics g) {

      super.paint(g);
      // the size of the component
      Dimension d = getSize();
      // the internal margins of the component
      // draw to fill the entire component
      g.drawImage(img, 0, 0, width, height, this);
      refresh();   
   }
   private void refresh(){
	   setVisible(false);
	   setVisible(true);
   }
   
      
}